package com.itcanteen.medical.patient.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Table;
import java.util.Date;

/**
 * 药品
 * @author 1804A-TeamOne
 * @date 2020-12-17 16:09
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "medication")
public class Medication extends BaseEntity {

    /**
     患者id
     */
    @Column(name = "patient_id", nullable = false)
    private Integer patientId;

    /**
     患者姓名
     */
    @Column(name = "patient_name", nullable = false)
    private String patientName;

    /**
     患者电话
     */
    @Column(name = "patient_phone", nullable = false)
    private String patientPhone;

    /**
     @param patient 患者对象 构造方法
     */
    public Medication (Patient patient) {
        this.patientId = patient.getId();
        this.patientPhone = patient.getPhone().toString();
        this.patientName = patient.getNickName();
        this.setCreateTime(new Date());
        this.setUpdateTime(new Date());
    }
}
